<!-- 搜索表单 -->
<template>
    <el-card shadow="never" >
      <el-form
        label-width="77px"
        class="ele-form-search"
        @keyup.enter.native="search"
        @submit.native.prevent
      >
        <el-row :gutter="15">
          <el-col :lg="9" :md="12">
            <el-form-item label="日期:">
              <el-date-picker v-model="where.date" :clearable="false" value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="daterange"
                  range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" >
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :lg="4" :md="12">
            <div class="ele-form-actions">
              <el-button
                type="primary"
                icon="el-icon-search"
                class="ele-btn-icon"
                @click="search"
              >
                查询
              </el-button>
              <el-button @click="reset">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    </template>
    
    <script>
      const DEFAULT_WHERE = {
        date: '',  //关键字
      };
      import moment from "moment"
      export default {
        name: 'ProfitSearch',
       
        data() {
          return {
            // 表单数据
            where: { date:[ moment().startOf('year').format('YYYY-01-01'),moment().endOf('year').format('YYYY-12-31')] },
          };
        },
        //初始化数据
        created(){
        },
    
        methods: {
    
          /* 搜索 */
          search() {
            let params = { sDate:moment().startOf('year').format('YYYY-01-01'),eDate:moment().endOf('year').format('YYYY-12-31')};
            
            //订单日期
            if(this.where.date){
              params.sDate = this.where.date[0] + " 00:00:00";
              params.eDate = this.where.date[1] + " 23:59:59";
            };

            this.$emit('search', params);
          },
          /*  重置 */
          reset() {
            this.where = { ...DEFAULT_WHERE };
            this.search();
          },
    
        }
      };
    </script>
    